/*
 * @Author: Villlee 15388605742@163.com
 * @Date: 2025-08-18 22:58:02
 * @LastEditors: Villlee 15388605742@163.com
 * @LastEditTime: 2025-08-26 22:21:15
 * @FilePath: /node-react-vite/midway-project/src/config/config.default.ts
 * @Description:
 *
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved.
 */
import { MidwayConfig } from '@midwayjs/core';

export default {
  // use for cookie sign key, should change to your own and keep security
  keys: '1755529082217_8494',
  koa: {
    port: 7001,
  },
  cors: {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
    credentials: true,
  },
  jwt: {
    secret: process.env.JWT_SECRET || 'my_secret_key', // 实际项目中应使用更复杂的密钥
    expiresIn: '2h', // token 过期时间
  },
  // 数据库配置
  typeorm: {
    dataSource: {
      default: {
        type: 'mysql',
        host: process.env.DB_HOST || '127.0.0.1',
        port: parseInt(process.env.DB_PORT || '3306'),
        username: process.env.DB_USERNAME || 'root',
        password: process.env.DB_PASSWORD || 'root',
        database: process.env.DB_DATABASE || 'midway_user',
        synchronize: process.env.NODE_ENV !== 'production', // 仅在非生产环境中使用
        logging: false,
        entities: ['**/entity/*.ts'],
        timezone: '+08:00',
      }
    }
  },
} as MidwayConfig;
